package com.zh.note.huawei.onehundred.双十一最大话费金额;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author: zhanghuan
 * @date: 2023/9/4 19:17
 * @description: create it
 * <p>
 * 23,26,36,27
 * 78
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // String line = sc.nextLine();
        // int target = sc.nextInt();
        String line = "23,26,36,27";
        int target = 78;
        int[] nums = Arrays.stream(line.split(",")).mapToInt(Integer::parseInt).toArray();
        int maxSum = 0;
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i++) {
            int left = i + 1;
            int right = nums.length - 1;
            while (left < right) {
                int sum = nums[i] + nums[left] + nums[right];
                if (sum <= target) {
                    maxSum = sum;
                    left++;
                } else {
                    right--;
                }
            }
        }
        System.out.println(maxSum);

    }
}
